help:
	@echo "Usage: make [targets]"
	@echo "targets:"
	@echo "  build        - Create a source package"
	@echo "  clean        - Get rid of scratch and byte files"
	@echo "  cleanall     - Clean env as well"
	@echo "  db           - Create database"
	@echo "  env          - Setup a virtualenv with requirements"
	@echo "  start        - Start this server"
	@echo "  test         - Execute the Unit Test"


# the Jenkins build system will override this value in the environment
VERSION?=1.0.0
BUILD_NUMBER?=1

build: env
	@sh -c ". env/bin/activate; python setup.py bdist_wheel; deactivate"

clean:
	rm -rf build dist
	rm -rf cplus.egg-info
	rm -rf .coverage coverage.xml nose2-junit.xml pylint.out
	find . -name "*.py[oc]" -delete
	find . -name "__pycache__" -delete

cleanall: clean
	rm -rf env

db: env
	@sh -c ". env/bin/activate; python -m cplus.create_db; deactivate"

env: requirements.txt
	@test -d env || virtualenv -p python env;
	@sh -c ". env/bin/activate; pip install -r requirements.txt; deactivate"

start: env db
	@sh -c ". env/bin/activate; python -m cplus"

PYTHON_FILES=`find cplus -name "*.py"`

test: env test-requirements.txt
	. env/bin/activate; pip install -r test-requirements.txt; nose2; deactivate
	. env/bin/activate; pylint --rcfile=pylint.cfg $(PYTHON_FILES) > pylint.out; echo